<template>
  <header>
    <div class="Leftcoent">
      <el-button
        plain
        @click="collapsMenu"
        icon="el-icon-menu"
        size="mini"
      ></el-button>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="current.path" v-if="current">
          {{ current.label }}
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <div class="rightcoent">
      <el-dropdown trigger="click">
        <span class="el-dropdown-link">
          <img :src="userImg" class="userIMG" alt="" />
        </span>

        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "CommonHeader",
  computed: {
    ...mapState({
      current: state => state.tab.currentMenu
    })
  },
  data() {
    return {
      userImg: require("../assets/images/user.png")
    };
  },
  methods: {
    collapsMenu() {
      this.$store.commit("collapseMenu");
    }
  }
};
</script>

<style lang="scss" scoped>
header {
  height: 100%;
  display: flex;
  /*横向居中*/
  align-items: center;
  /*水平布局 两端对齐*/
  justify-content: space-between;
}
.Leftcoent {
  display: flex;
  /*横向居中*/
  align-items: center;
  .el-button {
    margin-right: 20px;
  }
}
.rightcoent .userIMG {
  width: 45px;
  height: 45px;
  border-radius: 50%;
}
</style>
<!--组件嵌套不能使用scoped-->
<style lang="scss">
.el-breadcrumb__item {
  .el-breadcrumb__inner {
    color: #ffffff;
    font-weight: normal;
  }
  &:last-child {
    .el-breadcrumb__inner {
      color: #f4f4f4;
    }
  }
}
</style>
